<template>
	<div>
		<el-select
		    size="mini"
		    v-model="model_name"
		    filterable
		    remote
		    reserve-keyword
		    :placeholder="holder"
		    :remote-method="remoteMethod"
		    :loading="loading">
		    <el-option
		      v-for="item in options"
		      :key="item.id"
		      :label="item.model_name"
		      :value="item.model_name">
		    </el-option>
		  </el-select>
	</div>
</template>

<script>
	export default {
		data(){
			return {
				 loading:false,
				 options:[],
				 model_name:''
			}
		},
		props:{
			holder:{
				type:String,
				default:'请输入型号名称'
			}
		},
		watch:{
			model_name(newVal){
				this.$emit('getModelName',this.model_name)
			},
			// phone(newVal){
			// 	this.mid = newVal
			// },
		},
		mounted() {
			// this.phone = this.pphone
		},
		methods:{
			lodeModel(val){
				let params = {
					table_name:'hs_model',
					class_name:val,
					status:1
				}
				this.$post('/prodectSys/getBrandListNoPage',params,res=>{
					this.options = res.data.data
				})
			},
			remoteMethod(keywords) {
				if (keywords !== '') {
					 this.loading = true;
					 let params = {
						 keywords:keywords,
						 table_name:'hs_model',
						 key:'model_name'
					 }
					  this.$post('/prodectSys/searchBrandSerialModel',params,res=>{
						   this.loading = false
						  this.options = res.data.data
					  })
				} else {
				  this.options = [];
				}
		  }
		}
	}
</script>

